package com.bdqn.desiremall.command;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bdqn.desiremall.entity.Mall_ShippingAddress;
import com.bdqn.desiremall.serivce.shippingaddress.ShippingAddressSerivceImpl;
import com.bdqn.desiremall.serivce.shippingaddress.ShippingAddressService;
import com.mvc.command.ICommand;

public class ShippingAddress implements ICommand {
	ShippingAddressService addressService=new ShippingAddressSerivceImpl();
	Mall_ShippingAddress shippingnew=new Mall_ShippingAddress();
	public void Address(HttpServletRequest request,HttpServletResponse response)
	{
		shippingnew.setAddressId(5);
		shippingnew.setAddressName("张三");
		shippingnew.setUserId(2);
		shippingnew.setAddressPostcode(451011);
		shippingnew.setAddressPhone("18437620503");
		shippingnew.setIsDefault(2);
		shippingnew.setDetailedAddress("广州市天河区五山街道");
		if(addressService.addShippingAddress(shippingnew))
		{
			try {
				response.sendRedirect("Member_Address.jsp");
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	public void Amend(HttpServletRequest request,HttpServletResponse response)
	{
		Mall_ShippingAddress shippingnew=new Mall_ShippingAddress();
		shippingnew.setAddressId(1);
		shippingnew.setAddressName("张三2");
		shippingnew.setUserId(2);
		shippingnew.setAddressPostcode(451011);
		shippingnew.setAddressPhone("18437620503");
		shippingnew.setIsDefault(2);
		shippingnew.setDetailedAddress("广州市天河区五山街道");
		if(addressService.changeAddress(shippingnew))
		{
			try {
				response.sendRedirect("Member_Address.jsp");
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	public void Remove(HttpServletRequest request,HttpServletResponse response)
	{
			if(addressService.moveAddress(1))
			{
				try {
					response.sendRedirect("Member_Address.jsp");
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
	}
	
}
